package org.lee.middle.demo.controller;

import org.lee.middle.MiddleJointPoint;
import org.lee.middle.annotation.LeeMiddle;
import org.lee.middle.config.StarterService;
import org.lee.middle.demo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
public class HelloController {

    @Autowired
    StarterService starterService;
    @Autowired
    MiddleJointPoint point;

    @GetMapping("h")
    public String hello() {
        return "Hello world";
    }

    @LeeMiddle(key = "userId", returnJson = "{\"code\":408,\"message\":\"非白名单可访问用户拦截掉了\"}")
    @GetMapping("userInfo")
    public User userInfo(@RequestParam String userId) {
        String[] arg = starterService.split(",");
        return new User("lee" + userId, 18, "gd,sz,lh");
    }
}
